import request from '@/config/axios'

// 每日盈亏 VO
export interface ProfitLossDayVO {
  id: number // 主键
  balanceId: number // erp_balance的主键
  reportDate: Date // 报表日期
  nameCategory: string // 合约类型
  name: string // 合约名称
  buySell: string // 交易类型
  chargeFee: number // 手续费
  amount: number // 盈亏金额
  lots: number // 手数
  tradingMargin: number // 交易保证金
}

// 每日盈亏 API
export const ProfitLossDayApi = {
  // 查询每日盈亏分页
  getProfitLossDayPage: async (params: any) => {
    return await request.get({ url: `/erp/profit-loss-day/page`, params })
  },

  // 查询每日盈亏详情
  getProfitLossDay: async (id: number) => {
    return await request.get({ url: `/erp/profit-loss-day/get?id=` + id })
  },

  // 新增每日盈亏
  createProfitLossDay: async (data: ProfitLossDayVO) => {
    return await request.post({ url: `/erp/profit-loss-day/create`, data })
  },

  // 修改每日盈亏
  updateProfitLossDay: async (data: ProfitLossDayVO) => {
    return await request.put({ url: `/erp/profit-loss-day/update`, data })
  },

  // 删除每日盈亏
  deleteProfitLossDay: async (id: number) => {
    return await request.delete({ url: `/erp/profit-loss-day/delete?id=` + id })
  },

  // 导出每日盈亏 Excel
  exportProfitLossDay: async (params) => {
    return await request.download({ url: `/erp/profit-loss-day/export-excel`, params })
  },
}